<HTML><HEAD><TITLE>dim(?Term, ?Dimensions)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Term Manipulation</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>dim(?Term, ?Dimensions)</H1>
Creates a multi-dimensional array in the form of nested structures,
or computes the dimensions of an existing matrix.


<DL>
<DT><EM>Term</EM></DT>
<DD>Variable or structure.
</DD>
<DT><EM>Dimensions</EM></DT>
<DD>Variable or list of integers.
</DD>
</DL>
<H2>Description</H2>
    Creates a multi-dimensional array in the form of nested structures,
    or computes the dimensions of an existing matrix.

<P>
    When creating an array of dimensions [D1,..,Dn], a nested structure
    is created with the top-level term having the functor []/D1, its
    arguments being structures with functor []/D2, and so on.
    The functor [] is chosen to remind of arrays, but is otherwise
    not significant.

<P>
    To get the size of one-dimensional arrays, it is more efficient to
    use arity/2.

<H3>Modes and Determinism</H3><UL>
<LI>dim(+, -) is det
<LI>dim(-, ++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Both Term and Dimensions are not sufficiently instantiated.
<DT><EM>(5) type error </EM>
<DD>Dimensions is not a list of integers.
</DL>
<H2>Examples</H2>
<PRE>
[eclipse]: dim(M,[3,4]), dim(M,L).
M = []([](_131, _132, _133, _134),
       [](_126, _127, _128, _129),
       [](_121, _122, _123, _124))
L = [3, 4]
yes.



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termmanip/arg-3.html">arg / 3</A>, <A HREF="../../kernel/termmanip/arity-2.html">arity / 2</A>, <A HREF="../../kernel/termmanip/subscript-3.html">subscript / 3</A>, <A HREF="../../kernel/termmanip/flatten_array-2.html">flatten_array / 2</A>, <A HREF="../../kernel/termmanip/functor-3.html">functor / 3</A>
</BODY></HTML>
